<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="${path}/pages/">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生管理</title>
</head>
<body>
	<center>
		<h1>学生信息</h1><hr>
		<form method="post" action="${path}/upload" enctype="multipart/form-data">
			<table>
				<tr>
					<td>姓名：</td>
					<td><input type="text" name="name"></td>
				</tr>
				<tr>
					<td>学号：</td>
					<td><input type="text" name="sno"></td>
				</tr>
				<tr>
					<td>班级：</td>
					<td>
						<select name="clazzId" id="clazzId"></select>						
					</td>
				</tr>
				<tr>
					<td>头像：</td>
					<td><input type="file" name="myfile"></td>
				</tr>
			
				<tr align="center">
					<td colspan="2">
						<input type="submit" value="提交 ">
						<input type="reset" value="重置">
					</td>
				</tr>
			</table>
		</form>
	</center>
	
	<script src="../js/jquery-1.7.min.js"></script>
	<script>
		$(function() {
			$.getJSON('${path}/action/clazz/ajax', function(data) {
				// data是一个JSON对象
				//alert(JSON.stringify(data));
				
				var jq = $('#clazzId');
				jq.empty();
				for(var i=0; i<data.length; i++) {
					jq.append('<option value="'+data[i].id+'">' + data[i].name + '</option>');					
				}
			});	
		});
	</script>
</body>
</html>